<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'queryAndDelete.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
 <%@include file="/header.html" %>
        
</head>
<%String side_bar_page = basePath+"side_bar.jsp"; %>
  
<body >   

	 <div >
		<jsp:include page="/side_bar.jsp" flush="true"/> 
		<jsp:include page="/top_bar.jsp" flush="true"/> 

        </div>
 
 <div >


     <form action="my_dept_doQuery_success_deptMain.action" method="post">  
        <table align="center">  
            <tr>  
                <td style="vertical-align: middle;">DEPTNAME  
                    <input type="text" style="width: 300px;height: 30px;font-size: 16px" name="queryText"  value="${searchText }"/>  
                    <input type="submit" value="Query" style="width: 100px;height: 30px;font-size: 16px"/>  
                    <a href="/4L1Z/jsp/addDept.jsp">添加</a>   
                    <a href="/4L1Z/jsp/main.jsp">返回</a>  
                </td>  
            </tr>  
        </table>  
    </form>  

    <table id="t_dept" align="center" border="1" cellpadding="0" cellspacing="0" bordercolor="#3366cc">  
        <tr align="center" bgcolor="#3399cc" height="26px">  
            <td width="140">DeptID</td>  
            <td width="160">DeptName</td>  
           
            <td width="120">EDIT/DELETE</td>  
        </tr>  
           
       <c:forEach var="dept" items="${depts }">  
            <tr align="center"  height="24px">  
                <td width="100">${dept.deptid}</td>  
                 
                 <td width="150">${dept.deptname}</td>  
                <td width="120">  
                    <a href="editdept.action?param=0&deptid=${dept.deptid}">编辑</a>    
                    <a href="deletedept.action?deptid=${dept.deptid}">删除</a>  
                </td>  
            </tr>  
        </c:forEach>  
    </table>  
    
     <!-- 分页 -->
  <center>
    <div > 
        共有 <span id="spanTotalInfor"></span> 条记录     
        当前第<span id="spanPageNum"></span>页     
        共<span id="spanTotalPage"></span>页
    </div>
    <div >   
            <span id="spanFirst" >FIRST</span> 
            <span id="spanPre">UP</span>
            <span id="spanInput" style="margin: 0px; padding: 0px 0px 4px 0px; height:100%; "> 
                第<input id="Text1" type="text" class="TextBox" onkeyup="changepage()"   style="height:20px; text-align: center;width:50px" />页 
            </span>
            <span id="spanNext">DOWN</span> 
            <span  id="spanLast">LAST</span> 
        </div>
</center>
    <script type="text/javascript">
            var theTable = document.getElementById("t_dept");
            var txtValue = document.getElementById("Text1").value;
            function changepage() {
                var txtValue2 = document.getElementById("Text1").value;
                if (txtValue != txtValue2) {
                    if (txtValue2 > pageCount()) {

                    }
                    else if (txtValue2 <= 0) {

                    }
                    else if (txtValue2 == 1) {
                        first();
                    }
                    else if (txtValue2 == pageCount()) {
                        last();
                    }
                    else {
                        hideTable();
                        page = txtValue2;
                        pageNum2.value = page;

                        currentRow = pageSize * page;
                        maxRow = currentRow - pageSize;
                        if (currentRow > numberRowsInTable) currentRow = numberRowsInTable;
                        for (var i = maxRow; i < currentRow; i++) {
                            theTable.rows[i].style.display = '';
                        }
                        if (maxRow == 0) { preText(); firstText(); }
                        showPage();
                        nextLink();
                        lastLink();
                        preLink();
                        firstLink();
                   }

                    txtValue = txtValue2;
                }
            }
            
    </script>
    <script type="text/javascript" src="./js/Pagging.js"></script>
        <!-- 分页 -->
    
    
    
    
  
  </body>
</html>
